package Course;
import java.util.ArrayList;
import java.util.List;
public class Student {
    private String studentId;
    private String name;
    private String gender;
    private List<Course> selectedCourses = new ArrayList<>();

    // 构造方法
    public Student(String studentId, String name, String gender) {
        this.studentId = studentId;
        this.name = name;
        this.gender = gender;
    }

    // 选课方法
    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(name + " 成功选修 " + course.getCourseName());
    }

    // 退课方法
    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println(name + " 成功退选 " + course.getCourseName());
        } else {
            System.out.println(name + " 未选修 " + course.getCourseName() + "，退课失败");
        }
    }

    // 打印课表方法
    public void printCourseSchedule() {
        System.out.println("=== " + name + " 的课表 ===");
        System.out.println("编号\t课程名称\t上课地点\t时间\t授课教师");
        for (Course course : selectedCourses) {
            System.out.println(course.getCourseId() + "\t" + course.getCourseName() + "\t" + course.getLocation() + "\t" + course.getTime() + "\t" + course.getTeacher().getName());
        }
    }

    // Getter方法
    public String getStudentId() {
        return studentId;
    }
}
